import java.util.Scanner;
class UserInput {
	int lastInteger;
	int lastLength;
	String lastInput;
	private Scanner in = new Scanner(System.in);

	int getInteger(String prompt) {
		System.out.println(prompt);
		while(!in.hasNextInt()) {
			in.nextLine();
			System.out.println("Incorrect format. Try again.");
		}
		lastInteger = in.nextInt();
		return lastInteger;
	}
	int getLength(String prompt) {
		System.out.println(prompt);
		while(!in.hasNextInt() && !in.hasNext("[1-9][0-9]*")) {
			in.nextLine();
			System.out.println("Incorrect format. Try again.");
		}
		lastLength = in.nextInt();
		return lastLength;
	}
	void setInput(String input) {
		this.lastInput = input;
	}
}